1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package sun.nio.cs.ext;
27
28 import java.nio.charset.Charset;
29 import java.nio.charset.CharsetDecoder;
30 import java.nio.charset.CharsetEncoder;
31 import sun.nio.cs.HistoricallyNamedCharset;
32 import java.util.Arrays;
33 import static sun.nio.cs.CharsetMapping.*;
34
35 public class Big5_Solaris extends Charset implements HistoricallyNamedCharset
36 {
37 public Big5_Solaris() {
38 super("x-Big5-Solaris", ExtendedCharsets.aliasesFor("x-Big5-Solaris"));
39 }
40
41 public String historicalName() {
42 return "Big5_Solaris";
43 }
44
45 public boolean contains(Charset cs) {
46 return ((cs.name().equals("US-ASCII"))
47 || (cs instanceof Big5)
48 || (cs instanceof Big5_Solaris));
49 }
50
51 public CharsetDecoder newDecoder() {
52 initb2c();
53 return new DoubleByte.Decoder(this, b2c, b2cSB, 0x40, 0xfe);
54 }
55
56 public CharsetEncoder newEncoder() {
57 initc2b();
58 return new DoubleByte.Encoder(this, c2b, c2bIndex);
59 }
60
61 static char[][] b2c;
62 static char[] b2cSB;
63 private static volatile boolean b2cInitialized = false;
64
65 static void initb2c() {
66 if (b2cInitialized)
67 return;
68 synchronized (Big5_Solaris.class) {
69 if (b2cInitialized)
70 return;
71 Big5.initb2c();
72 b2c = Big5.b2c.clone();
73
74 int[] sol = new int[] {
75 0xF9D6, 0x7881,
76 0xF9D7, 0x92B9,
77 0xF9D8, 0x88CF,
78 0xF9D9, 0x58BB,
79 0xF9DA, 0x6052,
80 0xF9DB, 0x7CA7,
81 0xF9DC, 0x5AFA };
82 if (b2c[0xf9] == DoubleByte.B2C_UNMAPPABLE) {
83 b2c[0xf9] = new char[0xfe - 0x40 + 1];
84 Arrays.fill(b2c[0xf9], UNMAPPABLE_DECODING);
85 }
86
87 for (int i = 0; i < sol.length;) {
88 b2c[0xf9][sol[i++] & 0xff - 0x40] = (char)sol[i++];
89 }
90 b2cSB = Big5.b2cSB;
91 b2cInitialized = true;
92 }
93 }
94
95 static char[] c2b;
96 static char[] c2bIndex;
97 private static volatile boolean c2bInitialized = false;
98
99 static void initc2b() {
100 if (c2bInitialized)
101 return;
102 synchronized (Big5_Solaris.class) {
103 if (c2bInitialized)
104 return;
105 Big5.initc2b();
106 c2b = Big5.c2b.clone();
107 c2bIndex = Big5.c2bIndex.clone();
108 int[] sol = new int[] {
109 0x7881, 0xF9D6,
110 0x92B9, 0xF9D7,
111 0x88CF, 0xF9D8,
112 0x58BB, 0xF9D9,
113 0x6052, 0xF9DA,
114 0x7CA7, 0xF9DB,
115 0x5AFA, 0xF9DC };
116
117 for (int i = 0; i < sol.length;) {
118 int c = sol[i++];
119
120
121 c2b[c2bIndex[c >> 8] + (c & 0xff)] = (char)sol[i++];
122 }
123 c2bInitialized = true;
124 }
125 }
126 }